<?php
	/*
	** File: initialization
	** Description: Initialize system
	** Version: 1.0
	** Created: 01/04/2000
	** Author: Leon Atkinson
	** Email: leon@leonatkinson.com
	*/

	/*
	** Seed random number generator
	*/
	srand(time());

	/*
	** Generate browser information
	*/
	if(GENERATE_CLOAKING_CONSTANTS)
	{
		/*
		** Cloaking Variables 
		** Version 2.1
		** Leon Atkisnon <leon@clearink.com>
		** with contributions from:
		**	Chris Mospaw <mospaw@polk-county.com>
		**	Benjamin Elijah Griffin <bgriffin@cddb.com>
		**
		** This bit of code parses HTTP_USER_AGENT and sets the following variables:
		** Browser_Name
		** Browser_Version
		** Browser_Platform
		** Browser_JavaScriptOK
		** Browser_CSSOK
		** Browser_TextOnly
		** Browser_FileUpload
		**
		** JavaScriptOK means that the browser understands JavaScript on       
		** the same level the Navigator 3 does.  Specifically, it can use  
		** named images.  This allows easier rollovers.  If a browser doesn't
		** do this (Nav 2 or MSIE 3), then we just assume it can't do any 
		** JavaScript.  Referencing images by load order is too hard to maintain.                                 
		**
		** CSSOK is kind of sketchy in that Nav 4 and MSIE work differently,   
		** but they do seem to have most of the functionality.  MSIE 4 for the 
		** Mac has buggy CSS support, so we let it do JavaScript, but no CSS.  
		*/
	
		// Get the name the browser calls itself and what version
		$Browser_Name = strtok($HTTP_USER_AGENT, "/");
		$Browser_Version = strtok(" ");

		// MSIE lies about its name
		if(ereg("MSIE", $HTTP_USER_AGENT))
		{
			$Browser_Name = "MSIE";
			$Browser_Version = strtok("MSIE");
			$Browser_Version = strtok(" ");
			$Browser_Version = strtok(";");
		}
	
		// Opera isn't completely honest, either ...
		// Modificaton by Chris Mospaw <mospaw@polk-county.com>
		if(ereg("Opera", $HTTP_USER_AGENT))
		{
			$Browser_Name = strtok($HTTP_USER_AGENT, "/");
			$Browser_Name = "Opera";
			//$Browser_Version = strtok("Opera");
			//$Browser_Version = strtok("(");
			//$Browser_Version = strtok(";");
		}
	
	
		// try to figure out what platform, windows or mac
		$Browser_Platform = "unknown";
		
		if(ereg("Windows",$HTTP_USER_AGENT) ||
			ereg("NT 5.0",$HTTP_USER_AGENT) ||
			ereg("WinNT",$HTTP_USER_AGENT) ||
			ereg("Win98",$HTTP_USER_AGENT) ||
			ereg("Win95",$HTTP_USER_AGENT))
		{
			$Browser_Platform = "Windows";
		}
		
		if(ereg("Mac", $HTTP_USER_AGENT))
		{
			$Browser_Platform = "Macintosh";
		}
	
		if(ereg("X11", $HTTP_USER_AGENT)) 
		{ 
			$Browser_Platform =  "Unix"; 
		} 
	
		//default to no JavaScript or CSS support
		$Browser_JavaScriptOK = FALSE;
		$Browser_CSSOK = FALSE;
		$Browser_FileUpload = FALSE;
	
		if($Browser_Platform == "Windows")
		{
			if($Browser_Name == "Mozilla")
			{
				if($Browser_Version >= 3.0)
				{
					$Browser_TextOnly = FALSE;
					$Browser_JavaScriptOK = TRUE;
					$Browser_FileUpload = TRUE;
				}		
				if($Browser_Version >= 4.0)
				{
					$Browser_CSSOK = TRUE;
				}
			}
			elseif($Browser_Name == "MSIE")
			{
				if($Browser_Version >= 4.0)
				{
					$Browser_TextOnly = FALSE;
					$Browser_JavaScriptOK = TRUE;
					$Browser_FileUpload = TRUE;
					$Browser_CSSOK = TRUE;
				}		
			}
			elseif($Browser_Name == "Opera")
			{
				if($Browser_Version >= 3.0)
				{
					$Browser_JavaScriptOK = TRUE;
					$Browser_FileUpload = TRUE;
					$Browser_CSSOK = TRUE;
				}		
			}
		}
		elseif($Browser_Platform == "Macintosh")
		{
			if($Browser_Name == "Mozilla")
			{
				if($Browser_Version >= 3.0)
				{
					$Browser_JavaScriptOK = TRUE;
					$Browser_FileUpload = TRUE;
				}		
				if($Browser_Version >= 4.0)
				{
					$Browser_CSSOK = TRUE;
				}
			}
			elseif($Browser_Name == "MSIE")
			{
				if($Browser_Version >= 4.0)
				{
					$Browser_JavaScriptOK = TRUE;
					$Browser_CSSOK = TRUE;
					$Browser_FileUpload = TRUE;
				}		
			}
		}
		elseif($Browser_Platform ==  "Unix") 
		{ 
			if($Browser_Name ==  "Mozilla") 
			{ 
				if($Browser_Version >= 3.0) 
				{ 
					$Browser_JavaScriptOK = TRUE; 
					$Browser_FileUpload = TRUE; 
				}         
				if($Browser_Version >= 4.0) 
				{ 
					$Browser_CSSOK = TRUE; 
				} 
			} 
		}

		//Check where an ssl connection is being used.
		if($_SERVER["SERVER_PORT"] == 443){
			define('SSL_CONNECTION', TRUE);
		}else{
			define('SSL_CONNECTION', FALSE);
		}	
		
		//Create the constants
		//$Browser_JavaScriptOK = FALSE;
		//$Browser_Name = "GoogleBot";
		define('BROWSER_NAME', $Browser_Name);
		define('BROWSER_VERSION', $Browser_Version);
		define('BROWSER_PLATFORM', $Browser_Platform);
		define('BROWSER_JAVASCRIPTOK', $Browser_JavaScriptOK);
		define('BROWSER_CSSOK', $Browser_CSSOK);
		define('BROWSER_TEXTONLY', $Browser_TextOnly);
		define('BROWSER_FILEUPLOAD', $Browser_FileUpload);
		

	}
	
	// Make sure sessions are stored as cookies
	ini_set("session.use_cookies","1");	 
	//ini_set("session.use_trans_sid","1");
	//register globals set in .htaccess file
	//ini_set("register_globals","On");
	//define('BACKG_COLOUR_1', "#ffffc0");
	//define('BACKG_COLOUR_2', "#feefc0");
	define('BACKG_COLOUR_1', "white");
	define('BACKG_COLOUR_2', "#f7f7f7");
	$boBG = -1;
	//ob_start("ob_gzhandler");
	//ob_start();
	
	
	session_cache_limiter('nocache'); //should always be placed before session_start 
	session_start();
	
		//Hyperlinks taylored for seach engines. Only one parm is passed through
		/*if ($SESCREEN){
			

			$arrScreen = explode("X1X", "$SESCREEN");
			
			while (list ($key, $val) = each ($arrScreen)){


				eval("$$val;"); //variable variable must be in double quotes with a semi-colon
			}
			

			$SCREEN = $arrScreen[0];

			
		}*/
		
		if((DELIVERY_INCLUDED) && ($_SESSION['sesOrderTotal'] >= MIN_ORDER_VALUE )){
			define("CARRIAGE", "0.0");				// carriage charge if order is greater than threshold
		}else{
			define("CARRIAGE", MINIMUM_CARRIAGE);	// carriage charge
		}

?>
